package com.cloudfunx.common.exception;

import lombok.Getter;
import lombok.Setter;

/**
 * 业务异常类
 * @author linjiayu
 * @date 2019-08-11
 */
public class BizException extends RuntimeException {

    @Getter
    @Setter
    private Integer code;
    @Getter
    @Setter
    private String msg;

    @Getter
    @Setter
    private BizRetStatus bizRetStatus;

    public BizException(){
        this(BizRetStatus.FAIL);
    }

    public BizException(String message) {
        this(BizRetStatus.FAIL , message);
    }

    public BizException(BizRetStatus bizRetStatus) {
        super(bizRetStatus.getMsg());
        this.code = bizRetStatus.getCode();
        this.msg = bizRetStatus.getMsg();
        this.bizRetStatus = bizRetStatus;
    }

    public BizException(BizRetStatus bizRetStatus , String msg){
        super(msg);
        this.code = bizRetStatus.getCode();
        this.msg = msg;
        this.bizRetStatus = bizRetStatus;
    }
}
